DataSource for Entity Framework in WPF
C1.LiveLinq.LiveViews Namespace / View<T> Class / AttachAggregationView Method / AttachAggregationView<TResult>(Func<View<T>,AggregationView<T,TResult>>) Method
The type of the elements in the aggregation subview.
A function to obtain the attached aggregation subview from the view to which it is attached.
Example

In This Topic
    AttachAggregationView<TResult>(Func<View<T>,AggregationView<T,TResult>>) Method
    In This Topic
    Includes an aggregation subquery into the incremental maintenance mechanism of a view.
    Syntax
    'Declaration
     
    Public Overloads Function AttachAggregationView(Of TResult)( _
       ByVal selector As Func(Of View(Of T),AggregationView(Of T,TResult)) _
    ) As AggregationView(Of T,TResult)

    Parameters

    selector
    A function to obtain the attached aggregation subview from the view to which it is attached.

    Type Parameters

    TResult
    The type of the elements in the aggregation subview.

    Return Value

    The attached aggregation subview.
    Remarks

    Subquery is a query inside a function that is a part of an outer query. If the outer query is a live view, and its base data changes so it needs to recompute the function, by default it just evaluates the function, which means creating a new view object for the subquery on every such recomputation. To improve performance by avoiding repeated creation of subviews, use the AttachAggregationView method to make the outer view aware of its subview. Then the outer view will cache and reuse subview objects it creates.

    If there are more than one subviews attached to a single view, every subview must be supplied with a unique subview id by using the AttachAggregationView overload with subviewId parameter.

    var productView = from p in products join s in sales on p.ProductID equals s.ProductID into productSales select new { p.Name, ProductTotal = productSales.AttachAggregationView(v => v.LiveSum(s => s.Quantity)) };
    Example
    var productView =
        from p in products
        join s in sales on p.ProductID equals s.ProductID into productSales
        select new
        {
            p.Name,
            ProductTotal = productSales.AttachAggregationView(v => v.LiveSum(s => s.Quantity))
        };
    See Also